<template>
  <div>
    <!--面包屑-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!--卡片区域-->
    <el-card class="box-card">
      <!--表格数据-->
      <el-table
        :data="rightsList"
        border
        stripe
        style="width: 100%"
        max-height="650"
      >
        <el-table-column
          prop="id"
          label="#">
        </el-table-column>
        <el-table-column
          prop="authName"
          label="权限名称">
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径">
        </el-table-column>
        <el-table-column
          prop="level"
          label="权限等级">
          <template v-slot="slotItem">
            <el-tag v-if="slotItem.row.level == 1">一级</el-tag>
            <el-tag v-else-if="slotItem.row.level == 2" type="success">二级</el-tag>
            <el-tag v-else type="warning">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "rights",
  data(){
    return{
      rightsList: []
    }
  },
  created(){
    this.getAllRights();
  },
  methods: {
    getAllRights(){
      this.axios.get('rights/list').then(resp=>{
        if(resp.data.meta.status !== 200) return;

        //直接赋值
        this.rightsList = resp.data.data;
      }).catch(err=>{
        console.log(err)
      })
    }
  }
}
</script>

<style scoped>
.el-breadcrumb{
  font-size: 20px;
}
.box-card, .el-pagination{
  margin-top: 20px;
}
</style>

